package io.sage.modules.readsenseapi.controller;

import java.util.List;
import com.github.pagehelper.PageInfo;
import io.sage.modules.flow.service.FlowViewEventService;
import io.sage.modules.readsenseapi.entity.BFlowViewEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.sage.common.utils.R;



/**
 * 
 *
 * @author xujh
 * @email jhang_mail@163.com
 * @date 2019-08-06 18:10:59
 */
@RestController
@RequestMapping("flow/flowviewevent")
public class FlowViewEventController {
    @Autowired
    private FlowViewEventService flowViewEventService;

    /**
     * 列表
     */
    @RequestMapping("/list")
//    @RequiresPermissions("flow:flowviewevent:list")
    public R list(){
        List<BFlowViewEvent> bFlowViewEvents = flowViewEventService.selectFlowViewEventList(null);
        PageInfo<BFlowViewEvent> pageInfo = new PageInfo<BFlowViewEvent>(bFlowViewEvents);// 传入list就可以了
        return R.ok().put("bFlowViewEvents",pageInfo);
    }

    //增加删除修改功能已隐藏
    /**
     * 信息
     */
//    @RequestMapping("/info/{id}")
//    @RequiresPermissions("flow:flowviewevent:info")
    public R info(@PathVariable("id") String id){
        BFlowViewEvent flowViewEvent = flowViewEventService.selectByPrimaryKey(id);
        return R.ok().put("flowViewEvent", flowViewEvent);
    }

    /**
     * 保存
     */
//    @RequestMapping("/save")
//    @RequiresPermissions("flow:flowviewevent:save")
    public R save(@RequestBody BFlowViewEvent flowViewEvent){
        int insert = flowViewEventService.insert(flowViewEvent);
        if(insert>0){
            return R.ok();
        }
        return R.error();
    }

    /**
     * 修改
     */
//    @RequestMapping("/update")
//    @RequiresPermissions("flow:flowviewevent:update")
    public R update(@RequestBody BFlowViewEvent flowViewEvent){
        int upd = flowViewEventService.updateByPrimaryKeySelective(flowViewEvent);
        if(upd>0){
            return R.ok();
        }
        return R.error();
    }

    /**
     * 删除
     */
 //   @RequestMapping("/delete")
//    @RequiresPermissions("flow:flowviewevent:delete")
    public R delete(@RequestBody String[] ids){
        int del = flowViewEventService.deleteBatchIds(ids);
        if(del>0){
            return R.ok();
        }
        return R.error();
    }

}
